package alibaba.threadlocal.demo01;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

/**
 * @author ChangLiang
 * @date 2020/4/20
 */
@Slf4j
public class ThreadLocalTest {

    @Test
    public void test() throws InterruptedException {
        // 把User放到Thread t1的线程scope context中 于是在此线程中 调用的方法 就都可以从这个线程scope context中获取
        Thread t1 = new ProcessThread(new User("Bob", 120));

        Thread t2 = new ProcessThread(new User("Alice", 98));
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        log.info("main thread end");
    }
}
